package com.htgraph.contour;

import com.ht.impl.shape.ShapeRegister;
import com.mxgraph.util.mxRectangle;
import com.mxgraph.view.mxGraph;

/**
 * Created by IntelliJ IDEA.
 *
 * @author Dong Shufeng
 *         Date: 2010-6-22
 */
public class ContourRenderer_JGraph extends AbstractContourRenderer {
    mxGraph graph;

    public ContourRenderer_JGraph(mxGraph graph) {
        this.graph = graph;
    }

    public void buildGraph() {
        mxRectangle size = graph.getBoundingBoxFromGeometry(graph.getChildCells(graph.getDefaultParent()));
        ContourResult result = alg.doInterpolation(values, size.getRectangle());
        graph.getModel().beginUpdate();
        result.setColorMaker(colorMaker);
        Object cell = graph.insertVertex(graph.getDefaultParent(), null, result, size.getX(), size.getY(), size.getWidth(), size.getHeight(), "shape=" + ShapeRegister.SHAPE_CONTOUR);
        graph.orderCells(true, new Object[]{cell});
        graph.getModel().endUpdate();
    }
}
